package com.oocl.RTManageServer.server;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import com.oocl.constant.LogLevel;
import com.oocl.util.ConsoleLogUtil;
import com.oocl.util.ResourceCloser;

public class HttpServer {
	public void start(){
		ServerSocket server=null;
		try {
			server = new ServerSocket(9999);
			ConsoleLogUtil.log("httpServer start success...", LogLevel.INFO);
			while(true){
				Socket socket = server.accept();
				ConsoleLogUtil.log("A user connected to the server", LogLevel.INFO);
				new ServerThread(socket).start();
			}
		} catch (IOException e) {
			ConsoleLogUtil.log("httpServer server start wrong!"+e.getMessage(), LogLevel.ERROR);
			ResourceCloser.release(null, null, null, server);
		}finally {
			ResourceCloser.release(null, null, null, server);
			ConsoleLogUtil.log("httpServer server stop success...", LogLevel.INFO);
		}
	}
}
